import { inspectionAdmin } from '@/api/inspectionAdmin.js'
import store from './Logins'
import {upData} from '@/api/permissions'

export default {
    namespaced: true,
    state: {
        routers: []
    },
    mutations: {
        setrouter(state, route) {
            state.routers = route
        }
    },
    actions: {
        getrouter({ commit }, route) {
            let arr = [];
            arr = route.filter(item => {
                return !item.hidden
            })
            commit('setrouter', arr)
        },
        async setroute({ commit, dispatch, state }, items){
            let res = await inspectionAdmin(state.routers, items)
            if(res){
                let {data} = await upData({id: store.state.id, items: JSON.stringify(res)})
                return data.success
            }else{
                return true
            }
        }
    },
    getters: {}
}